package com.ecar.api.rest.order;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ecar.api.rest.AbstractResource;
import com.ecar.api.service.order.OrderLostService;
import com.ecar.api.support.dto.DriverDto;
import com.ecar.common.annotation.ResponseFilter;
import com.ecar.common.dto.DataBean;
import com.ecar.core.order.entity.OrderLost;

import net.sf.json.JSONObject;

/**
 * 类DriverController.java的实现描述：实现司机端相关业务处理
 * 
 * @author fire 2017-10-20
 */
@Controller
@Scope("prototype")
@Path("/lost")
public class OrderLostController extends AbstractResource{
	
	@Autowired
	OrderLostService orderLostService;
	
	/**
	 * 司机失物申报
	 * @author fire
	 * @param 
	 */
	@ResponseFilter(target = OrderLost.class, fields = {})
	@POST
	@Path("/setlost")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean setLost(JSONObject param) {
		try {
			if (!parse(param) || this.fields == null) return new DataBean(400, new JSONObject(),"请求参数格式错误！");
			
			log.info("司机:{}申报失物：｛｝" + this.fields.getString("driverId"),this.fields.toString());
			
			
			return orderLostService.insertLost(fields);
		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(),"添加用户失败。");
		}
	}

}
